package defense;

import java.awt.BorderLayout;
import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;

import javax.swing.JFrame;

public class Defense extends JFrame {
	private static final long serialVersionUID = -488550708407143737L;

	private DefensePanel defensePanel;

	public Defense() {
		super("Defense");
		defensePanel = new DefensePanel();
		this.getContentPane().setLayout(new BorderLayout());
		this.add(defensePanel, BorderLayout.CENTER);
		this.pack();
		this.setResizable(false);
		this.setVisible(true);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);

		Timer t = new Timer(true);
		t.schedule(new TimerTask() {
			@Override
			public void run() {
				updateFrame();
			}
		}, Calendar.getInstance().getTime(), 12);

		/*
		 * long lastTime = System.nanoTime() / 1000000; while (true) { try {
		 * long time = System.nanoTime() / 1000000; long sleepVal = 10 - (time -
		 * lastTime); System.out.println(sleepVal); if (sleepVal > 0)
		 * Thread.sleep(10 - (time - lastTime)); lastTime = System.nanoTime() /
		 * 1000000; } catch (InterruptedException e) { } updateFrame(); }
		 */
	}

	public void updateFrame() {
		defensePanel.repaint();
	}

	/**
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		new Defense();
	}
}
